package jay.home.bet.web.struts;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import jay.home.bet.domain.Event;
import jay.home.bet.misc.Util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class UpdateBanqianchangAction extends BaseAction {

	protected final Log log = LogFactory.getLog(getClass());
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		// TODO Auto-generated method stub

		String hh = request.getParameter("banquanchang.hh");
		String hd = request.getParameter("banquanchang.hd");
		String hr = request.getParameter("banquanchang.hr");
		String dh = request.getParameter("banquanchang.dh");
		String dd = request.getParameter("banquanchang.dd");
		String dr = request.getParameter("banquanchang.dr");
		String rh = request.getParameter("banquanchang.rh");
		String rd = request.getParameter("banquanchang.rd");
		String rr = request.getParameter("banquanchang.rr");
		String id = request.getParameter("id");
		
		log.info("banquanchang.hh = " + hh );
		log.info("banquanchang.hd = " + hd );
		log.info("banquanchang.hr = " + hr);
		log.info("banquanchang.dh = " + dh);
		log.info("banquanchang.dd = " + dd);
		log.info("banquanchang.dr = " + dr);
		log.info("banquanchang.rh = " + rh);
		log.info("banquanchang.rd = " + rd);
		log.info("banquanchang.rr = " + rr);
		log.info("id = " + id);
		
		Event event = getOddsService().getEventByComp(id);
		event.getBanquanchang().setHh(Util.toDouble(hh));
		event.getBanquanchang().setHd(Util.toDouble(hd));
		event.getBanquanchang().setHr(Util.toDouble(hr));
		event.getBanquanchang().setDh(Util.toDouble(dh));
		event.getBanquanchang().setDd(Util.toDouble(dd));
		event.getBanquanchang().setDr(Util.toDouble(dr));
		event.getBanquanchang().setRh(Util.toDouble(rh));
		event.getBanquanchang().setRd(Util.toDouble(rd));
		event.getBanquanchang().setRr(Util.toDouble(rr));
		getOddsService().updateEventsByComp(event);
		Map map = getOddsService().getCounter(event.getId());
		
		
		request.setAttribute("event", event);
		request.setAttribute("map", map);
		return mapping.findForward("SUCCESS");
	}
}
